﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.SaleInfos;

namespace Ue.Qcdz.Repositories.SaleInfos
{
    internal class SaleInfoFactory : IEntityFactory<SaleInfo>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string UserId="userId";
            public const string SalesType = "SalesType";
            public const string SalteTitle = "SalteTitle";
            public const string KeyWord = "KeyWord";
            public const string Period = "Period";
            public const string Directory = "Directory";
            public const string Brand = "Brand";
            public const string Model = "Model";
            public const string Description = "Description";
            public const string PicUrl = "PicUrl";
            public const string IsTop = "IsTop";
            public const string IsHot = "IsHot";
            public const string ShopId = "shopId";
            public const string SaleCategoryId = "SaleCategoryId";
            public const string Deadline = "Deadline";
            public class ShopFiledNames
            {
                public const string Id = "Id";
                public const string Name = "Name";
                public const string Remark = "Remark";
                public const string UId = "UserId";
            }
        }

        #region Implementation of IEntityFactory<SaleInfo>

        public SaleInfo BuildEntity(IDataReader reader)
        {
            return new SaleInfoProxy(
                reader.Get<string>(FieldNames.UserId),
                reader.Get<SaleInfoEnum>(FieldNames.SalesType),
                reader.Get<string>(FieldNames.SalteTitle),
                reader.Get<string>(FieldNames.KeyWord),
                reader.Get<PeriodDate>(FieldNames.Period),
                reader.Get<string>(FieldNames.Directory),
                reader.Get<string>(FieldNames.Brand),
                reader.Get<string>(FieldNames.Model),
                reader.Get<string>(FieldNames.Description),
                reader.Get<string>(FieldNames.PicUrl),
                reader.Get<DateTime>(FieldNames.CreateOn),
                reader.Get<IsTopEnum>(FieldNames.IsTop),
                reader.Get<IsHotEnum>(FieldNames.IsHot),
                reader.Get<string>(FieldNames.ShopId),
                reader.Get<string>(FieldNames.SaleCategoryId),
                reader.Get<DateTime>(FieldNames.Deadline),
                reader.Get<Guid>(FieldNames.EntityKey)
                );
        }

        #endregion
    }
}
